home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / wvnsrc75.zip / WVGLOB.H < prev    next >
C/C++ Source or Header  |  1992-11-23  |  16KB  |  453 lines

  1. /*---  This is WVGLOB.H  ------------------------------------------- */
  2. /* WVGLOB.H contains all the global types and variables for WinVN.   */
  3. /* Stylistically, this should probably be separated into several     */
  4. /* header files, but this is what you've got for now.                */
  5. /* cf WVDOC.C -- it describes some of these structures.              */
  6.  
  7. #define BUFSIZE   1024
  8. #define MAXFINDSTRING  80
  9. #define MAXSUBJECTSTRING 120
  10.  
  11. typedef long TypLineID;
  12.  
  13. typedef struct structdoc {
  14.    HANDLE hFirstBlock;        /* handle to first textblock in doc.        */
  15.    HANDLE hLastBlock;         /* unused.                                  */
  16.    unsigned int TotalLines;   /* total # of lines in doc.                 */
  17.    unsigned int ActiveLines;  /* # of selected or otherwise active lines  */
  18.    unsigned int BlockSize;    /* # of bytes in a textblock                */
  19.    unsigned int SplitSize;    /* textblock split point in bytes           */
  20.    HANDLE hCurAddBlock;       /* hBlock to point at which to add lines.   */
  21.    unsigned int AddOffset;    /* offset in bytes for point to add lines   */
  22.    TypLineID  AddLineID;      /* LineID of point to add lines.            */
  23.    HANDLE hCurTopScBlock;     /* hBlock of current top line of window     */
  24.    unsigned int TopScOffset;
  25.    TypLineID  TopScLineID;
  26.    unsigned int TopLineOrd;   /* ordinal in doc of line line in window    */
  27.    HANDLE hLastSeenBlock;
  28.    unsigned int LastSeenOffset;
  29.    TypLineID    LastSeenLineID;
  30.    HANDLE hFindBlock;         /* location of place to start next search   */
  31.    unsigned int FindOffset;   /* for "SearchStr"                          */
  32.    TypLineID    FindLineID;
  33.    unsigned int FindTextOffset;
  34.    char SearchStr[MAXFINDSTRING];  /* Search string for current search    */
  35.    unsigned int ScXChars;     /* # of chars/line for current window size  */
  36.    unsigned int ScYLines;     /* # of lines that fit in current window    */
  37.    unsigned int ScXWidth;     /* current size of client area of window    */
  38.    unsigned int ScYHeight;
  39.    HWND hDocWnd;
  40.    struct structdoc *ParentDoc;  /* pointer to parent document            */
  41.    HANDLE hParentBlock;          /* points to line in parent doc          */
  42.    unsigned int ParentOffset;    /* that corresponds to/describes this    */
  43.    TypLineID    ParentLineID;    /* document                              */
  44.    unsigned int OffsetToText;
  45.    BOOL          InUse;          /* TRUE if this TypDoc in use.           */
  46.    int          DocType;         /* DOCTYPE_xxx                           */
  47. #ifdef MAC
  48.    RECT  DocClipRect;      /* Current window clip rectangle          */
  49. #endif
  50. } TypDoc;
  51.  
  52. typedef struct structblock {
  53.    HANDLE hPrevBlock;     /* handle of previous block, or 0               */
  54.    HANDLE hNextBlock;     /* handle of next block in document, or 0       */
  55.    HANDLE hCurBlock;      /* handle of this block                         */
  56.    int    LWAp1;          /* # of used data bytes in block, inc header    */
  57.    int    NumLines;       /* # of lines in this block                     */
  58.    TypDoc *OwnerDoc;      /* pointer to document this block is in.        */
  59.    int    eob;            /* end-of-block; must be just before 1st line.  */
  60.    /* Text lines */
  61.    /* Another EOB marker */
  62. } TypBlock;
  63.  
  64. typedef struct structline {
  65.    int length;              /* Total # of bytes in line, all-inclusive    */
  66.    TypLineID LineID;        /* Unique identifier for this line.           */
  67.    /* Bytes of text */
  68.    /* Another copy of length */
  69. } TypLine;
  70.  
  71. typedef struct structtext {
  72.    int NameLen;            /* # of bytes of text                          */
  73. } TypText;
  74.  
  75. typedef struct structgroup {
  76.    char          Subscribed;      /* =TRUE if subscribed to this group.   */
  77.    char          Selected;        /* =TRUE if selected                    */
  78.    int           NameLen;         /* # of bytes in group name             */
  79.    TypDoc        *SubjDoc;        /* points to doc containing subjs       */
  80.    unsigned int  ServerEstNum;    /* est # of arts in server              */
  81.    long int  ServerFirst;     /* # of first art that server has.      */
  82.    long int  ServerLast;      /* # of last art that server has.       */
  83.    long int  HighestPrevSeen;     /* # of highest art server had in last  */
  84.                                   /* session, from "s<num>" newsrc field  */
  85.    HANDLE    header_handle;
  86.    long int    total_headers;    /* total # of headers in array */
  87.    int  nRanges;                  /* # of TypRanges describing seen arts  */
  88.    /* Name of group */            /* name of group, zero-terminated       */
  89.    /* Ranges of articles seen */  /* array of TypRanges, of seen articles */
  90. } TypGroup;
  91.  
  92. typedef struct structarticle {
  93.    long int Number;            /* Server's number for this article    */
  94.    char         Seen;              /* =TRUE if article seen               */
  95.    char         Selected;          /* =TRUE if article selected           */
  96.    TypDoc      *ArtDoc;            /* points to doc with actual article   */
  97.    int         NameLen;       /* # of bytes in subject line */
  98.    /* Subject line of article */
  99. } TypArticle;
  100.  
  101. /* this can now obsolete the article struct */
  102. /* #(++,10,#(++,6,#(++,4,#(++,#(++,#(++, 101, 75),30),30)))) */
  103. typedef struct {
  104.    char Seen;
  105.    char Selected;
  106.    unsigned int  number;
  107.    unsigned int  lines;
  108.    char date[6];
  109.    char subject[105];
  110.    char from[75];
  111.    char message_id[30];
  112.    char references[30];
  113.    TypDoc * ArtDoc;
  114. } TypHeader;
  115.  
  116. typedef struct structrange {
  117.    long int   First;
  118.    long int   Last;
  119. } TypRange;
  120.  
  121. /* TypMRRFile is used to describe a file; I use it because Windows  */
  122. /* doesn't provide much in the way of disk I/O support.                   */
  123.  
  124. typedef struct structMRRfile {
  125.    HANDLE   hFile;           /* handle to file                            */
  126. #ifdef MAC
  127.    int      vRef;
  128. #else
  129.    OFSTRUCT of;
  130. #endif
  131.    char     buf[BUFSIZE];    /* my I/O buffer.                            */
  132.    HANDLE   hthis;           /* handle to this structure                  */
  133.    int      bufidx;          /* Index to next place in buf                */
  134.    int      bytesread;       /* for reads, # of bytes read in last read   */
  135.    int      mode;            /* mode in which to open file.               */
  136.    int      eofflag;         /* whether we have reached EOF (read)        */
  137. } TypMRRFile;
  138.  
  139. #define MAXCHARS 80
  140. #define MAXLINES 24
  141. #define MAXCOMMLINE      140
  142. #define MAXINTERNALLINE   180
  143. #define MAXOUTLINE    255
  144. #define CtoX(c) (c*CharWidth + SideSpace)
  145. #define LtoY(l) (l*LineHeight + TopSpace)
  146.  
  147. #define EDITID   1      /* ID of edit box, to identify for return values */
  148. #define MAXMEMONAME 15  /* Number of chars in memo name */
  149. #define MEMONAMECHARS (MAXMEMONAME+2)
  150. #define MAXVIEWS 10
  151. #define END_OF_BLOCK (-1)
  152. #define BLOCK_SIZE  1024
  153. /*  RangeOffset gives the number of bytes from the beginning of
  154.  *  a Group structure to the first Range field, given the length
  155.  *  of the name entry.
  156.  */
  157. #define RangeOffset(nlen) (((nlen+2)/2)*2 + sizeof(TypGroup))
  158.  
  159. #ifdef WINMAIN
  160. #define DEF
  161. #else
  162. #define DEF extern
  163. #endif
  164.  
  165. DEF TypDoc NetDoc;
  166.  
  167. #define MRR_SCROLL_LINEUP    0
  168. #define MRR_SCROLL_LINEDOWN  1
  169. #define MRR_SCROLL_PAGEUP    2
  170. #define MRR_SCROLL_PAGEDOWN  3
  171.  
  172.  
  173. /* This structure maps between keystrokes and mouse events.
  174.  * From an idea on p. 137 of Charles Petzold's book.
  175.  * If you change the definition, be sure to update NUMKEYS.
  176.  */
  177. #define NUMKEYS 4
  178. #ifndef MAC
  179. struct {
  180.    WORD wVirtKey;
  181.    int CtlState;
  182.    int iMessage;
  183.    WORD wRequest;
  184. } key2scroll[NUMKEYS]
  185. #ifdef WINMAIN
  186. =
  187. {VK_PRIOR, 0, WM_VSCROLL,SB_PAGEUP,
  188.  VK_NEXT,  0, WM_VSCROLL,SB_PAGEDOWN,
  189.  VK_UP,    1, WM_VSCROLL,SB_LINEUP,
  190.  VK_DOWN,  1, WM_VSCROLL,SB_LINEDOWN
  191. }
  192. #endif
  193. ;
  194. #endif
  195.  
  196. DEF BOOL Initializing;
  197. #define INIT_DONE                0
  198. #define INIT_READING_NEWSRC      1
  199. #define INIT_ESTAB_CONN          2
  200. #define INIT_SCANNING_NETDOC     3
  201. #define INIT_GETTING_LIST        4
  202.  
  203. #define MAXGROUPWNDS   4
  204. #define MAXARTICLEWNDS 4
  205. #define MAXPOSTWNDS    4
  206. #define MAXMAILWNDS    4
  207.  
  208. DEF TypDoc GroupDocs[MAXGROUPWNDS];
  209. DEF TypDoc ArticleDocs[MAXARTICLEWNDS];
  210. DEF TypDoc PostingDocs[MAXPOSTWNDS];
  211. DEF TypDoc MailDocs[MAXMAILWNDS];
  212. DEF HWND  hWndPosts[MAXPOSTWNDS];
  213. DEF HWND  hWndMails[MAXMAILWNDS];
  214. #ifndef MAC
  215. DEF HWND  hWndPostEdits[MAXPOSTWNDS];
  216. DEF HWND  hWndMailEdits[MAXMAILWNDS];
  217. #else
  218. DEF TEHandle TEHPosts[MAXPOSTWNDS];
  219. DEF TEHandle TEHCurrent;
  220. DEF ControlHandle    vScroll;
  221. DEF int           linesInFolder;
  222. #endif
  223.  
  224. #define DOCTYPE_UNKNOWN  0
  225. #define DOCTYPE_NET      1
  226. #define DOCTYPE_GROUP    2
  227. #define DOCTYPE_ARTICLE  4
  228. #define DOCTYPE_POSTING  8
  229. #define DOCTYPE_MAIL     16
  230.  
  231. /* Variables and constants for handling the FSA used to deal with    */
  232. /* talking to the NNTP server.                                       */
  233.  
  234. DEF int CommState;        /* current state in comm FSA                        */
  235. DEF BOOL CommBusy;        /* =TRUE if comm line busy interacting w/ server    */
  236. DEF TypDoc *CommDoc;      /* Document currently receiving lines from server   */
  237. DEF char CommLineIn[MAXCOMMLINE];  /* current input line being built by FSA   */
  238. DEF char *CommLinePtr;    /* pointer to next place to put char in CommLineIn  */
  239. DEF char *CommLineLWAp1;  /* if we get this far, we're at end of buffer       */
  240. DEF char IgnoreCommCh;    /* char to ignore when reading from server          */
  241. DEF char EOLCommCh;       /* char that indicates end of line upon input       */
  242. DEF TypDoc *ActiveGroupDoc;
  243. DEF TypDoc *ActiveArticleDoc;
  244. DEF BOOL SaveNewsrc;      /* =TRUE iff we write NEWSRC upon exit */
  245.  
  246. #define MAXGROUPNAME 80
  247. DEF char CurrentGroup[MAXGROUPNAME]; /* name of group currently selected on server */
  248.  
  249. DEF BOOL UsingSocket;     /* =TRUE if using PC/TCP rather than serial I/O     */
  250. #define MAXNNTPSIZE 40
  251. DEF char NNTPHost[MAXNNTPSIZE];
  252. DEF int NNTPPort;
  253.  
  254. #define MAILLEN 48
  255. DEF char MailAddress[MAILLEN];
  256. DEF char UserName[MAILLEN];
  257. DEF char Organization[MAILLEN];
  258.  
  259.  
  260. /* States in the FSA that cracks input lines from the server.             */
  261.  
  262. #define ST_NONE                    0
  263. #define ST_ESTABLISH_COMM          1
  264. #define ST_GROUP_RESP              2
  265. #define ST_XHDR_RESP               3
  266. #define ST_XHDR_SUBJ               4
  267. #define ST_IN_GROUP                5
  268. #define ST_ARTICLE_RESP            6
  269. #define ST_REC_ARTICLE             7
  270. #define ST_POST_WAIT_PERMISSION    8
  271. #define ST_POST_WAIT_END           9
  272. #define ST_GROUP_REJOIN           10
  273. #define ST_LIST_RESP              11
  274. #define ST_LIST_GROUPLINE         12
  275. #define ST_MAIL_WAIT_PERMISSION   13
  276. #define ST_MAIL_WAIT_END          14
  277. #define ST_XHDR_FROM_START      50
  278. #define ST_XHDR_FROM_DATA      51
  279. #define ST_XHDR_SUBJ_START      52
  280. #define ST_XHDR_SUBJ_DATA      53
  281. #define ST_XHDR_REF_START      54
  282. #define ST_XHDR_REF_DATA      55
  283. #define ST_XHDR_MID_START      56
  284. #define ST_XHDR_MID_DATA      57
  285. #define ST_XHDR_DATE_START      58
  286. #define ST_XHDR_DATE_DATA      59
  287. #define ST_XHDR_LINES_START      60
  288. #define ST_XHDR_LINES_DATA      61
  289.  
  290.  
  291. #define LFN_HELP "WINVN.HLP"
  292.  
  293. /* variables used in an ad hoc attempt to optimize updating of windows by
  294.  * the input cracking FSA.
  295.  */
  296.  
  297. #define UPDATE_TITLE_FREQ    10
  298. #define UPDATE_ART_FREQ    12
  299. #define MAX_IMMEDIATE_UPDATE  2
  300. DEF unsigned int RcvLineCount;
  301. DEF unsigned int TimesWndUpdated;
  302.  
  303. DEF TypLineID NextLineID  /* LineID to assign to next created line            */
  304. #ifdef WINMAIN
  305. = 10664L
  306. #endif
  307. ;
  308.  
  309. DEF HANDLE hInst;
  310. DEF HWND   hWndConf;   /* handle to NetDoc window                             */
  311. DEF HWND   hWndSk;
  312. DEF HWND   hDosWnd;
  313.  
  314. #ifndef MAC
  315. HANDLE hAccel;     /* handle to main accelerator table */
  316. MSG MainMsg;       /* message returned from GetMessage */
  317.  
  318. int CommDevice;    /* comm device ID, if using serial I/O                 */
  319. #endif
  320.  
  321.  
  322. DEF char str[255];                              /* general-purpose string buffer */
  323.  
  324. #ifndef MAC
  325. HCURSOR hSaveCursor;                        /* handle to current cursor      */
  326. HCURSOR hHourGlass;                         /* handle to hourglass cursor    */
  327. #endif
  328.  
  329. DEF int X, Y;                                   /* last cursor position          */
  330.  
  331. #ifndef MAC
  332. POINT ptCursor;                             /* x and y coordinates of cursor */
  333.  
  334. DCB DCBComm;
  335. #define MAXCOMMCHARS 40
  336. char szCommString[MAXCOMMCHARS];    /* string describing serial comm port */
  337. #endif
  338.  
  339. DEF int xPos, yPos;
  340.  
  341. DEF int ViewNew;
  342. DEF int NewArticleWindow;
  343. DEF int SelectAll;
  344. DEF int NViews;
  345. DEF int DoList;
  346.  
  347. /* AskComm says whether to put up the communications dialog box
  348.  * upon starting up.  Options are never, always, and yes, because
  349.  * this is the first time the program has been run.
  350.  */
  351. #define ASK_COMM_NEVER    0
  352. #define ASK_COMM_ALWAYS   1
  353. #define ASK_COMM_INITIAL  2
  354. DEF int AskComm;
  355. DEF BOOL ArticleFixedFont;
  356.  
  357. DEF unsigned int xScreen, yScreen;
  358. DEF HANDLE hFont;   /* handle to font used in all windows except article       */
  359. DEF HANDLE hFontArt;  /* handle to font used in Article window. */
  360. DEF int FontSize;
  361. DEF int ArticleFontSize;
  362. DEF int FontBold;
  363. DEF char FontFace[32];
  364. DEF char ArticleFontFace[32];
  365.  
  366. DEF int LineHeight,CharWidth;  /* # of window units for current font          */
  367. DEF int ArtLineHeight, ArtCharWidth; /* # of windows units for article font */
  368. DEF int TopSpace, SideSpace;   /* # of window units to leave at top and side  */
  369.                            /* of window (for aesthetic purposes)          */
  370. DEF int StartPen;      /* Similar to TopSpace; where to start pen 1st row */
  371.  
  372. DEF DWORD OldTextColor, OldBkColor;
  373. DEF DWORD NetUnSubscribedColor;  /* color to use for unsubscribed groups  */
  374. DEF DWORD GroupSeenColor;        /* color to use for articles that have been seen */
  375. DEF int ReverseVideo;
  376. DEF BOOL ThumbTrack;
  377. #ifdef MAC
  378. DEF RgnHandle BigClipRgn;
  379. DEF   Rect  myClipRect;
  380.  
  381. DEF Handle netMenuBar,groupMenuBar,articleMenuBar,postMenuBar;
  382. DEF MenuHandle gAppleMenu;
  383. DEF MenuHandle gOptionsMenu;
  384. #endif
  385.  
  386. #ifndef MAC
  387. FARPROC lpfnWinVnSaveArtDlg;
  388. FARPROC lpfnWinVnFindDlg;
  389. FARPROC lpfnWinVnSubjectDlg;
  390. FARPROC lpfnWinVnCommDlg;
  391. FARPROC lpfnWinVnAuthDlg;
  392. FARPROC lpfnWinVnDoListDlg;
  393. FARPROC lpfnWinVnPersonalInfoDlg;
  394. FARPROC lpfnWinVnMiscDlg;
  395. FARPROC lpfnWinVnAppearanceDlg;
  396. char *szAppName;
  397. char szAppProFile[80];
  398. #endif
  399.  
  400. DEF BOOL Authorized;
  401.  
  402. #define MAXFILENAME 60
  403. DEF char SaveArtFileName[MAXFILENAME];
  404. DEF char SubjectString[MAXSUBJECTSTRING];
  405. DEF int  SaveArtvRef;   /* volume ref num used only by Mac */
  406. DEF int  SaveArtAppend;
  407.  
  408. DEF TypDoc *PostDoc;   /* Used to pass pointer to article being replied to. */
  409. DEF TypDoc *MailDoc;
  410. DEF TypDoc *FindDoc;
  411. DEF char *NewsgroupsPtr;  /* Used to pass pointer to newsgroup of new posting. */
  412.  
  413. /* For each new group detected, we create an entry in the following
  414.  * array, NewGroupTable.  Each entry contains a far pointer to a
  415.  * dynamically-allocated global data structure containing:
  416.  *  -- Handle to this structure (so we can deallocate later).
  417.  *  -- A line containing information on this group, in the exact
  418.  *     same format as used in the NetDoc.
  419.  */
  420. DEF void far * far * NewGroupTable;  /* array of pointers to new group lines */
  421. DEF HANDLE hNewGroupTable;     /* Handle to the above array */
  422. DEF int nNewGroups;
  423.  
  424. #define ADD_SUBSCRIBED_END_OF_SUB 0
  425. #define ADD_SUBSCRIBED_TOP_OF_DOC        1
  426.  
  427. #define LINE_FLAG_SET        0
  428.  
  429. #define GROUP_ACTION_SUBSCRIBE    0
  430. #define GROUP_ACTION_UNSUBSCRIBE  1
  431.  
  432. DEF int il,ic;
  433. DEF int irow;
  434. DEF int imemo;
  435. DEF int ih;
  436.  
  437. #define MAXCOMMSPEEDCHARS 7
  438.  
  439. DEF int CommPortID;     /* IDD_COM1 or IDD_COM2 */
  440. DEF int CommParityID;   /* IDD_7EVEN or IDD_8NONE  */
  441. DEF char pszCommSpeed[MAXCOMMSPEEDCHARS];  /* character version of comm speed */
  442.  
  443. DEF int idTimer;                                          /* timer ID            */
  444.  
  445. #ifndef MAC
  446. #define IncPtr(ptr,byint) (char far *)ptr += byint
  447. #endif
  448.  
  449. #include <string.h>
  450.  
  451.  
  452. /*--- Last line of WVGLOB.H -------------------------------------------- */
  453.